import Vue from 'vue';
import Vuex from 'vuex';
import { config } from 'vuex-module-decorators';
import VuexPersistence from 'vuex-persist';

import { ICounterState } from './modules/counter';

config.rawError = true;
Vue.use(Vuex);

export interface IRootState {
  counter: ICounterState;
}

const vuexStorage = new VuexPersistence<IRootState>({
  modules: ['counter']
});

export default new Vuex.Store<IRootState>({
  plugins: [vuexStorage.plugin]
});
